<template>
  <!-- 授权用户 -->
  <el-dialog title="阅读情况" :visible.sync="visible" width="800px" top="5vh" append-to-body>
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
      <el-form-item label="查看部门" prop="deptName">
        <el-input v-model="queryParams.deptName" placeholder="请输入部门" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="回执情况" prop="receiptStatus">
        <el-select class="select-width" v-model="queryParams.receiptStatus" filterable clearable placeholder="请选择回执情况">
          <el-option v-for="(item, index) in types" :key="index" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row>
      <el-table ref="table" :data="userList" height="260px">
        <el-table-column label="序号" type="index" align="center" />
        <el-table-column label="姓名" prop="readerName" />
        <el-table-column label="部门" prop="deptName" />
        <el-table-column label="状态" align="center" prop="status">
          <template slot-scope="scope">
            <span :style="getColor(scope.row)">{{ getReceipt(scope.row) }}</span>
          </template>
        </el-table-column>
      </el-table>
    </el-row>
    <div slot="footer" class="dialog-footer">
      <el-button @click="visible = false">关闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { auditInfo } from "../../../api/xzgl/hytz";
export default {
  props: {
    // 角色编号
    replyId: {
      type: [Number, String]
    }
  },
  data() {
    return {
      // 遮罩层
      visible: false,
      // 未授权用户数据
      userList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        deptName: undefined,
        userName: undefined,
      },
      types: [
        { label: '未回执', value: ''},
        { label: '参会', value: ''},
        { label: '请假', value: ''},
      ]
    };
  },
  methods: {
    // 显示弹框
    show() {
      console.log('replyId', this.replyId)
      this.getList();
      this.visible = true;
    },
    // 查询表数据
    getList() {
      const params = {
        id: this.replyId
      }
      auditInfo(params).then(res => {
        this.userList = res.data.noticeInfos;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    getColor(row){
      const status = row.receiptStatus
      if(status=='UNDO'){
        return 'color: #FF6060'
      }else if(status=='DONE'&&row.meetAttendStatus==1){
        return 'color: #CE9410'
      }else{
        return 'color: #63C945'
      }
    },
    getReceipt(row){
      if(row.receiptStatus=='UNDO'){
        return row.receiptStatusName
      }else if(row.receiptStatus=='DONE'&&row.meetAttendStatus==1){
        return '请假' + row.receiptMemo
      }else{
        return row.receiptMemo
      }
    }
  }
};
</script>
